package net.acoinWork.demo.dao.impl;

import net.acoinWork.demo.dao.DemoDao;
import net.acoinWork.demo.dao.MockDao;
import net.acoinWork.demo.pojo.DemoPerson;
import net.acoinWork.dynRender.organize.Organizer;
import org.apache.velocity.VelocityContext;

import java.util.Date;
import java.util.List;

/**
 * 演示dao
 *
 * @author xusk
 * @Date: 15/12/31 下午3:58
 */
public class DemoDaoVelocityImpl extends MockDao implements DemoDao {
    private static final Organizer<VelocityContext> organizer =
            new Organizer<VelocityContext>("/demoDaoVelocity.xml");

    /**
     * 演示一个dao的方法如何使用
     *
     * @param list
     * @return
     */
    @Override
    public List<Object> getListByAges(List<DemoPerson> list) {
        final Date o = new Date();
        VelocityContext ctx = new VelocityContext();
        ctx.put("list", list);
        final List<Object> result = query(organizer.getResById("getListByAges", ctx));
        System.out.println("timeCost:" + (new Date().getTime() - o.getTime()) + "ms");
        return result;
    }

}
